<template>
  <view class="dayTradeMain">
    <u-sticky :enable="enable">
      <view
        class="dayTradeHeader solid-bottom flex align-center justify-between"
      >
        <view class="flex align-center" v-if="queryData.data_type == 1"
          >{{ renderData.hzfSelectName
          }}<text v-if="renderData.hzfSelectName != '我的交易'"
            >合作方</text
          ></view
        >
        <view class="flex align-center" v-if="queryData.data_type == 2"
          >{{ renderData.qyfSelectName }}<text>签约方</text></view
        >
        <text>{{ queryData.month }}</text>
      </view>
    </u-sticky>
    <view class="dayTradeBox">
      <view v-if="(renderData.tradeList).length > 0">
        <!-- <view class="item solid-bottom flex " v-for="(item, index) in renderData.tradeList" :key="index" @click="dayTradeTap(item)"> -->
        <view class="item solid-bottom flex " v-for="(item, index) in renderData.tradeList" :key="index">
			<view>
				<text>{{ item.date }}</text>
				<view>总交易额：<text>{{ item.total == "0" ? "0.00" :$tools.format(item.total) }}元</text></view>
			</view>
			<!-- <u-icon name="arrow-right" size="30" color="#b0b0b0"></u-icon> -->
        </view>
      </view>
	    <view class="noMachine" v-if="(renderData.tradeList).length == 0 && isLoad">
        <image
          src="../../static/images/noData/zwjl.png"
          mode="widthFix"
        ></image>
        <text>暂无交易</text>
      </view>
    </view>
    <toast></toast>
  </view>
</template>
<script>
export default {
  data() {
    return {
      enable: true,
	  isLoad:false,
      renderData: {
        hzfSelectName: "",
        qyfSelectName: "",
        tradeList: [],
      },
      queryData: {
        data_type: "",
        user_id: "",
        month: "",
      },
    };
  },
  onLoad(options) {
    this.renderData.hzfSelectName = options.hzfSelectName;
    this.renderData.qyfSelectName = options.qyfSelectName;
    this.queryData.data_type = options.data_type;
    this.queryData.user_id = options.user_id;
    this.queryData.month = options.month;
    this.getDayTradeList();
  },
  onShow() {
    this.enable = true;
  },
  onHide() {
    this.enable = false;
  },
  methods: {
    getDayTradeList() {
      this.$u.api
        .dayTradeList({
          user_id: this.queryData.user_id,
          data_type: this.queryData.data_type,
          month: this.queryData.month,
        })
        .then((res) => {
          if (res.status == 200) {
            this.renderData.tradeList = res.result;
          }
		  this.isLoad = true;
        })
		.catch((res) => {
			if (res.errMsg == "request:fail timeout") {
				this.$u.toast("请求超时，请重试!");
			} else if (res.errMsg == "request:fail") {
				this.$u.toast("请求失败，请重试");
			} else {
				 this.$u.toast("请求失败，请重试");
			}
			this.$loading(false);
			setTimeout(() => {
				this.$u.route({
					type: "navigateBack",
					delta: 1,
				});
			}, 2000);
		});
    },
	
	dayTradeTap(data){
		this.$u.route({
		  url:'/pages/trade/tradeUserDetail',
		  params:{
			dayData:data.date,
			userId:this.queryData.user_id
		  }
		})
	}
  },
};
</script>
<style lang="scss" scoped>
page {
  background: #fff;
}
.dayTradeHeader {
  padding: 30rpx;
  background: #fff;
  view {
    font-weight: bold;
    text {
      line-height: 40rpx;
      padding: 0 10rpx;
      color: #fff;
      background: #fb4535;
      font-size: 24rpx;
      border-radius: 6rpx;
      transform: scale(0.8);
      margin-left: 5rpx;
      display: block;
      position: relative;
      top: 3rpx;
    }
  }
  > text {
    font-weight: bold;
  }
}
.dayTradeBox {
  .item {
    padding: 18rpx 30rpx;
	flex-direction: row;
	justify-content: space-between;
    > text {
      font-size: 28rpx;
      color: #333;
      font-weight: bold;
	  margin-top: 10rpx;
    }
    > view {
      text {
        font-family: "numberFont";
        font-size: 32rpx;
        letter-spacing: 2rpx;
      }
    }
  }
}
</style>